package org.csu.mypetstore.controller;

import org.springframework.ui.Model;
import org.csu.mypetstore.domain.Order;
import org.csu.mypetstore.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/order/view")
public class ViewOrderController {

    @Autowired
    private OrderService orderService;

    // 查看订单详情
    @GetMapping("/{orderId}")
    public String viewOrder(
            @PathVariable int orderId,
            Model model) {

        Order order = orderService.getOrderDetails(orderId);
        model.addAttribute("order", order);
        return "order/ViewOrder";
    }
}
